﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Progetto
{
    public class ReadTextFile
    {
        private FileStream fs;
        private StreamReader sw;

        private const string path = @"C:\Users\Alessandro Avila\Polito\Primo anno\Programmazione di sistema\C++\";

        private static string fileName;

        public ReadTextFile(string fileName) {
            ReadTextFile.fileName = fileName;
        }

        public Dictionary<string, UInt32> getNetworkList() {

            fs = new FileStream(path + fileName, FileMode.Open);
            sw = new StreamReader(fs);

            Dictionary<string, UInt32> network_list = new Dictionary<string, uint>();
            string line;

            while((line = sw.ReadLine()) != null) {
                string[] objects = new string[2];
                objects = line.Split(':');
                network_list.Add(objects[0], Convert.ToUInt32(objects[1]));
            }

            sw.Close();
            fs.Close();

            return network_list;

        }

        public void close() {
            sw.Close();
            fs.Close();
        }
    }
}